﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class RoleRelationTemplateCls
    {
        public string RoleRelationTemplateId;
        public string RoleRelationTemplateName;
        public int  SortIndex = 0;
        public string XmlData;
        public string AssetCode;
    }

    public class RoleRelationTemplateParser
    {
        public static RoleRelationTemplateCls CreateInstance()
        {
            //tao 1 class trang....
            RoleRelationTemplateCls oRoleRelationTemplateCls = new RoleRelationTemplateCls();
            return oRoleRelationTemplateCls;
        }

        public static RoleRelationTemplateCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            RoleRelationTemplateCls oRoleRelationTemplateCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oRoleRelationTemplateCls;
        }


        public static RoleRelationTemplateCls ParseFromDataRow(DataRow dr)
        {
            RoleRelationTemplateCls ORoleRelationTemplateCls = new RoleRelationTemplateCls();
            ORoleRelationTemplateCls.RoleRelationTemplateId = XmlUtility.GetString(dr, "RoleRelationTemplateId", true);
            ORoleRelationTemplateCls.RoleRelationTemplateName = XmlUtility.GetString(dr, "RoleRelationTemplateName", true);
            ORoleRelationTemplateCls.AssetCode = XmlUtility.GetString(dr, "AssetCode", true);
            ORoleRelationTemplateCls.SortIndex = XmlUtility.GetInt(dr, "SortIndex", true);
            return ORoleRelationTemplateCls;
        }

        public static RoleRelationTemplateCls[] ParseFromDataTable(DataTable dtTable)
        {
            RoleRelationTemplateCls[] RoleRelationTemplates = new RoleRelationTemplateCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                RoleRelationTemplates[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return RoleRelationTemplates;
        }
    }
}




